package com.wyg.composite.observer;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Observer;

/**
 * @description:
 * @author: WYG
 * @time: 2021/4/10 21:57
 */

public class Observable implements QuackObservable{
    private ArrayList<Observer> observers = new ArrayList<>();
    QuackObservable duck;
    public Observable(QuackObservable duck) {
        this.duck = duck;
    }
    @Override
    public void registerObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void notifyObservers() {
        Iterator<Observer> iterator = observers.iterator();
        while (iterator.hasNext()) {
            Observer observer = (Observer) iterator.next();
        }
    }
}
